/**
 * kig
 * 2006
 */

#include "Util.h"
#include "Scene.h"
#include "Canvas.h"
#include "Ray.h"

#ifndef KIG_EYE_H
#define KIG_EYE_H

namespace kig
{
	/**
	 * Combines Ray with Canvas information.
	 */
	struct EyeRay 
	{
		/**
		 * The actual Ray.
		 */
		Ray r;

		/**
		 * x coordinate on the Canvas the Ray corresponds with.
		 */
		unsigned int x;

		/**
		 * x coordinate on the Canvas the Ray corresponds with.
		 */
		unsigned int y;
	};
	
	/**
	 * The Eye ditacts how the Artist sees the Scene.
	 * It is responsible for shooting rays into the Scene. 
	 * This just implements a very simple Eye.
	 */
	class Eye 
	{
		public:
			/**
			 * Constructor.
			 * @param c the Canvas associated with the Eye
			 * @param dis distance from the Eye to the Canvas
			 */
			Eye() : _canvas(0), _distanceToCanvas(5.0),
					_xStep(0.0), _yStep(0.0),
					_fX(0.0), _fY(0.0),
					_curX(0), _curY(0)
			{
				// empty
			}

			/**
			 * Set the Canvas being used.
			 * @param c the Canvas
			 * @param d distance from the Eye to the Canvas
			 */
			void setCanvas(Canvas* c, Float dis=5.0);
			
			/**
			 * Return true if the Eye needs to shoot more Rays.
			 */
			bool moreRays();
				
			/**
			 * Return the next Ray.
			 */
			EyeRay nextRay();
			
			/**
			 * The description...
			 */
			std::string getDesc() const {
				return "Standard eye";
			}
	
			/**
			 * Destructor.
			 */
			virtual ~Eye() 
			{
				// empty
			}
		protected:
			/**
			 * The current Canvas to draw on.
			 */
			CanvasPtr _canvas;

			/**
			 * Distance from the current Canvas to the Eye.
			 */
			Float _distanceToCanvas;

			Float _xStep;
			Float _yStep;
			Float _fX;
			Float _fY;
			unsigned int _curX;
			unsigned int _curY;
	};

}

#endif
